package com.wondertek.poms.core.service.impl;

import org.springframework.stereotype.Service;

import com.wondertek.poms.common.service.impl.ServiceImpl;
import com.wondertek.poms.core.service.IPrdRuleSecondClassifyService;
import com.wondertek.poms.dao.po.PrdRuleSecondClassify;
import com.wondertek.poms.dao.repo.IPrdRuleSecondClassifyDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Set;

/**
 * <p><b>PcProductRuleServiceImpl Description:</b> 二级产品规则 service层实现 </p>
 *
 * @author 窦再兴
 * <p><b>DATE</b> 2020-10-16 15:56:15</p>
 */
@Service
public class PrdRuleSecondClassifyImpl extends ServiceImpl<PrdRuleSecondClassify, Long> implements IPrdRuleSecondClassifyService {
	@Autowired
	private IPrdRuleSecondClassifyDao prdRuleSecondClassifyDao;

	@Override
	public PrdRuleSecondClassify deleteLogic(Long id) {
		return null;
	}

	@Override
	public PrdRuleSecondClassify merge(PrdRuleSecondClassify model) {
		return null;
	}

	@Override
	public Set<PrdRuleSecondClassify> findAllByPrdRuleId(Long prdRuleId) {
		return prdRuleSecondClassifyDao.findAllByPrdRuleId(prdRuleId);
	}

	@Override
	@Transactional
	@Modifying
	public int deleteAllByPrdRuleId(Long prdRuleId) {
		return prdRuleSecondClassifyDao.deleteAllByPrdRuleId(prdRuleId);
	}

	@Override
	public PrdRuleSecondClassify update(PrdRuleSecondClassify model) {
		PrdRuleSecondClassify dbo = prdRuleSecondClassifyDao.findByPrdRuleId(model.getPrdRuleId());
		BeanUtils.copyProperties(model, dbo);
		return jpaRepository.save(dbo);
	}
}
